-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Export JsValue from js-sys #3466
Conversation
I don't think I would mind that. Could you add this to the changelog as well? |
@daxpedda Yea, I think re-exporting entire The downside is that unrelated parts of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The downside is that unrelated parts of
wasm-bindgen
are exported as well (for example, you can annotate your methods with a#[js_sys::wasm_bindgen::wasm_bindgen]
macro, which makes little sence, but going with a fine comb to reexport only the types used seems like a lot of work.
Reexports like this are just to make it easier to use dependencies without having to pull in sub-dependencies. So it's fine like this, it's a known pattern in Rust.
This is an opinionated change anyway, so we will wait for another maintainer to chime in.
453f280
to
c6ef799
Compare
If this is done, I don't think it should be done in just js-sys. Why not web-sys as well? |
I agree. WDYT overall though? |
I'm not a fan of it. All it saves is one line in Cargo.toml. But I also can't think of a reason not to add it |
It's generally considered good behavior to re-export crates that you use types of in your public API, which is the case for us in But I'm happy to proceed now @kajacx if you finish this up. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also re-export wasm-bindgen
and js-sys
from web-sys
.
Yea, but tracking down that line is non-trivial. You have to go to the source of If you could use On the other hand, if someone uses my crate, and they want to use In the end, this is a preference decision, so I think it's best to keep it to the authors of the crate to make the final call. For example, I will not be exporting |
@kajacx this is still missing, otherwise this is good to go. |
This way, you can name the JsValue type without adding a dependency on wasm-bindgen.
Co-authored-by: daxpedda <daxpedda@gmail.com>
5655390
to
cc03d6b
Compare
Done. |
Thanks! |
This way, you can name the
JsValue
type without adding a dependency onwasm-bindgen
.On the other hand
js-sys
already depends onwasm-bindgen
, so it's not that bad. Still, returning a type (or requiring it as an argument) that your crate doesn't provide simply feels wrong.